const mongoose = require("mongoose")
const Schema = mongoose.Schema

const Common_User_Type = {
    username: {
        type: String,
        unique: true,
        required: true,
        minLength: [2, '用户名最短为2'],
        maxLength: [10, '用户名最长为10'],

    },
    password: {
        type: String,
        require: [true, "必填密码"],
        minLength: [6, '密码最短为6'],

    },
    avatar: {
        type: String,
        default: "/images/user/default.png"
    },
    role: {
        type: String,
        enum: {
            values: ['0', '1'],
            message: "只能从0或1选择"
        },
        default: "1"
    },
    cryptogram: {
        type: String,
        require: [true, "必填密码"],
        minLength: [6, '密码最短为6'],
    }

}


const Common_User_Model = mongoose.model("commonUser", new Schema(Common_User_Type))



module.exports = Common_User_Model